<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="_meta :: header">
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form form form-horizontal" id="allotAudio" action="#" method="post">
<!--            <select id="status" name="status" >-->
<!--                <option value="" text="请选择">请选择</option>-->
<!--                <option th:each="g:${username}"  th:value="${g.value}" th:text="${g.value}"-->
<!--                        >${g.value}-->
<!--                </option>-->
<!--            </select>-->
<!--            <input th:value="${ids}" name="ids" id="ids" type="hidden" />-->
<!--            <button  class="layui-btn" id="subbtn" type="submit">-->
<!--                分配-->
<!--            </button>-->

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>分配校对人：</label>
                <div class="layui-input-inline">
                    <select id="status" name="status" >
                        <option th:each="g:${username}"  th:value="${g.value}" th:text="${g.value}">${g.value}
                        </option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>分组名称：</label>
                <div class="layui-input-inline">
                    <div class="layui-input-inline">
                        <input type="layui-input" class="layui-input" t name="name"  placeholder="请输入分组名称" id="userId"/>
                    </div>
                </div>
            </div>

            <input id="draftId" type="hidden" name="draftId" th:value="${draftId}">
            <input id="ids" type="hidden" name="ids" th:value="${ids}">
            <input id="updateTime" type="hidden" name="updateTime" >
            <input id="createTime" type="hidden" name="createTime" >
            <div class="layui-form-item" >
                <label class="layui-form-label">
                    <button  class="layui-btn" id="subbtn" type="submit">
                        分配
                    </button>
                </label>
            </div>
        </form>

    </div>
    <!--_footer 作为公共模版分离出去-->
    <div th:replace="_footer :: footerjs"></div>
    <div th:replace="_ueditor :: ueditor"></div>
    <!--/_footer 作为公共模版分离出去-->
    <!--请在下方写此页面业务相关的脚本-->
    <script>

        layui.use(['laydate','form'], function(){
            var laydate = layui.laydate;
            var form = layui.form;
            // 监听全选
            form.on('checkbox(checkall)', function(data){
                if(data.elem.checked){
                    $('tbody input').prop('checked',true);
                }else{
                    $('tbody input').prop('checked',false);
                }
                form.render('checkbox');
            });
            form.on('select(selectchange)', function(data){
                console.log(data.value); //得到被选中的值
                var pageNo = $('#pageNo');
                var Form = $('form')
                pageNo.val(1);
                Form.submit();
                form.render('select');
            });
            //日期时间范围选择
            laydate.render({
            });
            lay('.timeSpace').each(function(){
                laydate.render({
                    elem: this
                    ,type: 'datetime'
                    ,range: true //或 range: '~' 来自定义分割字符
                });
            });
        });
        $(function () {
            $("#allotAudio").validate({
                rules:{
                    checker:{
                        required: true,
                    },
                    name:{
                        required: true,
                    }
                },
                onkeyup:false,
                debug: true,
                success:"valid",
                submitHandler:
                    function (form) {
                        var status=$('#status').val();
                        if (status==""){
                            layer.msg("请选择下属");
                            return false;
                        }
                        $.lock()
                        $(form).ajaxSubmit({
                            type: 'POST',
                            url: "/admin/draft/allotAudioDraft",
                            success: function (data) {
                                console.log("数据"+data);
                                if (data.code == "1") {
                                    selfmsg('分配成功!', 1, function () {
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.location.reload();
                                        parent.layer.close(index);
                                        $.unlock()
                                    });
                                } else {
                                    selfmsg(data.msg,null,null,2);
                                    $.unlock()
                                }
                            },
                            error: function () {
                                selfmsg('分配异常!', 5);
                                $.unlock()
                            }
                        });
                    }
            })
        })

        // layui.use(['form', 'layer','laydate'],function() {
        //     $ = layui.jquery;
        //     var form = layui.form,
        //         laydate = layui.laydate,
        //         layer = layui.layer;
        //     lay('.timeSpace').each(function(){
        //         laydate.render({
        //             elem: this
        //             ,trigger: 'click'
        //             ,type: 'datetime'
        //         });
        //     });
        // });
        // $(function () {
        //     $("#allotAudio").validate({
        //         rules: {
        //             allotId:
        //                 {
        //                     required: true,
        //                 },
        //             allotnoId:
        //                 {
        //                     required: true,
        //                 },
        //
        //
        //
        //         },
        //         onkeyup:false,
        //         debug
        //             :
        //             true,
        //         success
        //             :
        //             "valid",
        //         submitHandler:
        //             function (form) {
        //                 $(form).ajaxSubmit({
        //                     type: 'POST',
        //                     url: "/admin/draft/allotAudioDraft",
        //                     success: function (data) {
        //                         if (data.code == "1") {
        //                             selfmsg('分配成功!', 1, function () {
        //                                 var index = parent.layer.getFrameIndex(window.name);
        //                                 parent.location.reload();
        //                                 parent.layer.close(index);
        //                             });
        //                         } else {
        //                             selfmsg('分配失败!');
        //                         }
        //                     },
        //                     error: function () {
        //                         selfmsg('分配异常!', 5);
        //                     }
        //                 });
        //             }
        //     })
        //     ;
        // });

    </script>
    <!--/请在上方写此页面业务相关的脚本-->
</div>
</body>
</html>